import {Component, OnInit, ViewChild} from '@angular/core';

import {DynamicFormService} from './dynamic-form.service';

@Component({
    templateUrl: './dynamic-form.component.html',
    styleUrls: ['./dynamic-form.component.css']
})
export class DynamicFormComponent implements OnInit {
    forms = [];
    formData = null;

    @ViewChild('kylinForm') kylinForm;

    constructor(private dynamicFormService: DynamicFormService) {
    }

    ngOnInit() {
        this.forms = this.dynamicFormService.forms();
    }


    formDataChange($event) {
        this.formData = $event;
    }

    submit() {
        this.kylinForm.onSubmit({state: '123456789'});
    }

    reset() {
        this.kylinForm.reset();
    }

}
